/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sim.DAL;

import java.io.Serializable;
import java.sql.ResultSet;


/**
 *
 * @author rafik
 */

public class UserProfile implements Serializable {

    private Integer id;
    private String fullName;
    private String street;
    private String city;
    private String province;
    private String country;
    private String postelCode;
    private int roleId;

    //Constructeur par default
    public UserProfile() {
    }

    public UserProfile(int id) {
       String query = "SELECT * FROM UserProfile u WHERE u.id = '"+ id +"' ";
       try {
        DBConnection db = new DBConnection();
        ResultSet rs = db.executeSql(query);

        while(rs.next()){
        //Recuperer les informations de la base de donnees
        this.fullName = rs.getString("full_name");
        this.street = rs.getString("street");
        this.city = rs.getString("city");
        this.province = rs.getString("province");
        this.country = rs.getString("country");
        this.postelCode = rs.getString("postel_code");
        }
       }catch (Exception e){
        System.err.print(e);
       }
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getPostelCode() {
        return postelCode;
    }

    public void setPostelCode(String postelCode) {
        this.postelCode = postelCode;
    }

    public int getRoleId() {
        return roleId;
    }

    public void setRoleId(int roleId) {
        this.roleId = roleId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserProfile)) {
            return false;
        }
        UserProfile other = (UserProfile) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sim.DAL.UserProfile[id=" + id + "]";
    }

}
